/**
 * Debug macros to access the syslog api.
 */

#ifndef EGDEBUG_H_
#define EGDEBUG_H_

/**
 * Starts the cronometer in t1.
 */
void tic(struct timeval *t1);

/**
 * Returns the elapsed time in miliseconds since t1 started.
 * @param t1 the time of started cronometer.
 */
long int tac(struct timeval t1);

#ifdef DEBUG

#warning "DEBUG defined."

//#define EG_INI() openlog("e-glue", LOG_ODELAY | LOG_CONS, LOG_USER); \
//				 setlogmask(LOG_UPTO(LOG_DEBUG))
#define EG_INI() openlog("e-glue", LOG_ODELAY | LOG_PERROR, LOG_USER); \
				 setlogmask(LOG_MASK(LOG_ERR | LOG_INFO | LOG_DEBUG))
#define EG_ERR(__format, ...) syslog(LOG_ERR, __format, ## __VA_ARGS__)
#define EG_INF(__format, ...) syslog(LOG_INFO, __format, ## __VA_ARGS__)
#define EG_DEB(__format, ...) syslog(LOG_DEBUG, __format, ## __VA_ARGS__)
#define EG_END() closelog()

#else

#define EG_INI() /* empty definition */
#define EG_ERR(__format, ...) /* empty definition */
#define EG_INF(__format, ...) /* empty definition */
#define EG_DEB(__format, ...) /* empty definition */
#define EG_END() /* empty definition */

#endif

/**
 * This is a enum table to debug purposes. This table lists the features you want to measure time.
 */
typedef enum {
    FINDFEATURES=0,
    GLUEIMAGE,
    SIFT1,
    SIFT2,
    KDTREE,
    RANSAC,
    MAX_TIME_TABLE_INDEX
} timetableindex_t;

void showTimeTable();
void initTimeTable();

#endif /*EGDEBUG_H_*/
